package io.lkt.modules.sys.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.lkt.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.lkt.modules.sys.entity.BPosterDictEntity;
import io.lkt.modules.sys.service.BPosterDictService;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.R;



/**
 * 海报分类表
 *
 * @author xss
 * @email dustwas@163.com
 * @date 2020-12-01 16:25:18
 */
@RestController
@RequestMapping("/sys/bposterdict")
public class BPosterDictController {
    @Autowired
    private BPosterDictService bPosterDictService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("sys:bposterdict:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bPosterDictService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @RequestMapping("/queryAll")
//    @RequiresPermissions("sys:bposterdict:queryAll")
    public R queryAll(@RequestBody BPosterDictEntity bPosterDictEntity){
        List<BPosterDictEntity> bPosterDict = bPosterDictService.queryAll(bPosterDictEntity);
        return R.ok().put("bPosterDict", bPosterDict);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
//    @RequiresPermissions("sys:bposterdict:info")
    public R info(@PathVariable("id") Integer id){
        BPosterDictEntity bPosterDict = bPosterDictService.getById(id);

        return R.ok().put("bPosterDict", bPosterDict);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("sys:bposterdict:save")
    public R save(@RequestBody BPosterDictEntity bPosterDict){
        bPosterDictService.save(bPosterDict);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("sys:bposterdict:update")
    public R update(@RequestBody BPosterDictEntity bPosterDict){
        ValidatorUtils.validateEntity(bPosterDict);
        bPosterDictService.updateById(bPosterDict);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("sys:bposterdict:delete")
    public R delete(@RequestBody Integer[] ids){
        bPosterDictService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
